<?php
class Login_Data_AddUser {
	
	public $database;
	
	public function __construct(){
		$this->database = new Core_Driver_MysqlImproved();
	}
	
	public function add(array $postVars){
		$this->database->connect();
		$realname = $postVars['realname'];
		$username = $postVars['name'];
		$email = $postVars['email'];
		$password = $postVars['password'];
		$language = $postVars['language'];
		
		$realname = $this->database->escape($realname);
		$username = $this->database->escape($username);
		$email = $this->database->escape($email);
		$password = $this->database->escape($password);
		$language = $this->database->escape($language);
		
		$this->database->prepare(
			"
				insert into users(users_language, users_realname,users_username, users_email, users_password, users_banned, users_access_level) values('$language', '$realname', '$username', '$email', '$password', false, 5);
				"
		);
		$this->database->query();
		$this->database->dataOperations();
		echo '<meta http-equiv="Refresh" content="0;url='.SERVER_ROOT.'?login&page=login">';	
		
	}
}